package uk.ac.ed.ogte;

import net.sourceforge.ondex.core.ConceptClass;
import net.sourceforge.ondex.core.ONDEXConcept;
import net.sourceforge.ondex.core.ONDEXRelation;
import uk.ac.ed.ogte.nodepath.EvidencePathNode;

/**
 * A state in the state machine that determines if a concept is a valid position
 * The Node must represent a ConceptClass of the metagraph
 *
 * @author hindlem
 *
 */
public class Node implements QueryGraphComponent<ONDEXConcept, EvidencePathNode<ONDEXConcept, ONDEXRelation, Node>> {

    private final ConceptClass cc;

    /**
     * @param cc the required ConceptClass this Node represents
     */
    public Node(ConceptClass cc) {
        this.cc = cc;
    }

    /**
     * @return the required ConceptClass this Node represents
     */
    public ConceptClass getValidConceptClass() {
        return cc;
    }

    /**
     * @param c the concept to check
     * @return is it valid to traverse this concept
     */
    public boolean isValid(ONDEXConcept c, EvidencePathNode<ONDEXConcept, ONDEXRelation, Node> p) {
        return cc.equals(c.getOfType());
    }


    public String toString() {
        return "Node for " + cc.getId();
    }

}
